<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/
Route::get('/oss/sts', [\App\Http\Controllers\OssController::class, 'getSts']);
Route::post('/oss/upload', [\App\Http\Controllers\OssController::class, 'uploadFile']);

Route::prefix('/test')->group(function () {

    Route::post('/assistant-rank', [\App\Http\Controllers\TestApiController::class, 'createAssistantRank']);
    Route::post('/user-rank', [\App\Http\Controllers\TestApiController::class, 'createUserRank']);
    Route::post('/sms-code', [\App\Http\Controllers\TestApiController::class, 'sendSmsCode']);
});

Route::prefix('/crm')->group(function () {

    Route::post('/login', [\App\Http\Controllers\CRM\LoginController::class, 'login']);
    Route::middleware("auth:sanctum")->group(function () {

        //小程序管理
        Route::prefix('/mini_app')->group(function () {

            //充值选项
            Route::prefix('/recharge/options')->group(function () {

                Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\MemberRechargeOptionController::class, 'getList']);
                Route::get('/{option}', [\App\Http\Controllers\CRM\MiniAPP\MemberRechargeOptionController::class, 'getInfo']);
                Route::post('/', [\App\Http\Controllers\CRM\MiniAPP\MemberRechargeOptionController::class, 'create']);
                Route::put('/{option}', [\App\Http\Controllers\CRM\MiniAPP\MemberRechargeOptionController::class, 'edit']);
                Route::delete('/{option}', [\App\Http\Controllers\CRM\MiniAPP\MemberRechargeOptionController::class, 'remove']);
            });

            //助教
            Route::prefix('/assistants')->group(function () {

                Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\AssistantController::class, 'getList']);
                Route::post('/', [\App\Http\Controllers\CRM\MiniAPP\AssistantController::class, 'create']);
                Route::get('/{assistant}', [\App\Http\Controllers\CRM\MiniAPP\AssistantController::class, 'getInfo'])->where(['assistant' => '[0-9]+']);
                Route::put('/{assistant}', [\App\Http\Controllers\CRM\MiniAPP\AssistantController::class, 'edit'])->where(['assistant' => '[0-9]+']);
                Route::delete('/{assistant}', [\App\Http\Controllers\CRM\MiniAPP\AssistantController::class, 'remove'])->where(['assistant' => '[0-9]+']);
                Route::put('/{assistant}/detail', [\App\Http\Controllers\CRM\MiniAPP\AssistantController::class, 'editDetail'])->where(['assistant' => '[0-9]+']);

                Route::prefix('/types')->group(function () {

                    Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\AssistantTypeController::class, 'getList']);
                    Route::post('/', [\App\Http\Controllers\CRM\MiniAPP\AssistantTypeController::class, 'create']);
                    Route::get('/{type}', [\App\Http\Controllers\CRM\MiniAPP\AssistantTypeController::class, 'getInfo']);
                    Route::put('/{type}', [\App\Http\Controllers\CRM\MiniAPP\AssistantTypeController::class, 'edit']);
                    Route::delete('/{type}', [\App\Http\Controllers\CRM\MiniAPP\AssistantTypeController::class, 'remove']);
                });

                Route::prefix('/reserves')->group(function () {

                    Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\AssistantReserveController::class, 'getList']);

                    Route::prefix('/{reserve}')->group(function () {

                        Route::put('/success', [\App\Http\Controllers\CRM\MiniAPP\AssistantReserveController::class, 'reserveSuccess']);
                        Route::put('/fail', [\App\Http\Controllers\CRM\MiniAPP\AssistantReserveController::class, 'reserveFail']);
                    })->where(['reserve' => '[0-9]+']);
                });
            });

            //台桌
            Route::prefix('/tables')->group(function () {

                Route::prefix('/reserves')->group(function () {

                    Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\TableReserveController::class, 'getList']);
                    Route::prefix('/{reserve}')->group(function () {

                        Route::put('/success', [\App\Http\Controllers\CRM\MiniAPP\TableReserveController::class, 'reserveSuccess']);
                        Route::put('/fail', [\App\Http\Controllers\CRM\MiniAPP\TableReserveController::class, 'reserveFail']);
                    })->where(['reserve' => '[0-9]+']);
                })->where(['reserve' => '[0-9]+']);

                Route::prefix('/types')->group(function () {

                    Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\TableTypeController::class, 'getList']);
                    Route::post('/', [\App\Http\Controllers\CRM\MiniAPP\TableTypeController::class, 'create']);
                    Route::get('/{type}', [\App\Http\Controllers\CRM\MiniAPP\TableTypeController::class, 'getInfo']);
                    Route::put('/{type}', [\App\Http\Controllers\CRM\MiniAPP\TableTypeController::class, 'edit']);
                    Route::delete('/{type}', [\App\Http\Controllers\CRM\MiniAPP\TableTypeController::class, 'remove']);
                });
            });

            //约球对战
            Route::prefix('/duels')->group(function () {

                Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\DuelController::class, 'getDuelList']);
                Route::prefix('/{duel}')->group(function () {

                    Route::put('/success', [\App\Http\Controllers\CRM\MiniAPP\DuelController::class, 'reviewSuccess']);
                    Route::put('/fail', [\App\Http\Controllers\CRM\MiniAPP\DuelController::class, 'reviewFail']);
                })->where(['duel' => '[0-9]+']);

                Route::prefix('/types')->group(function () {

                    Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\DuelTypeController::class, 'getList']);
                    Route::post('/', [\App\Http\Controllers\CRM\MiniAPP\DuelTypeController::class, 'create']);
                    Route::delete('/{type}', [\App\Http\Controllers\CRM\MiniAPP\DuelTypeController::class, 'remove']);
                });

                Route::prefix('/levels')->group(function () {

                    Route::get('/', [\App\Http\Controllers\CRM\MiniAPP\DuelLevelController::class, 'getList']);
                    Route::post('/', [\App\Http\Controllers\CRM\MiniAPP\DuelLevelController::class, 'create']);
                    Route::delete('/{level}', [\App\Http\Controllers\CRM\MiniAPP\DuelLevelController::class, 'remove']);
                });
            });

        });

        //员工管理
        Route::prefix('/users')->group(function () {

            //通知规则
            Route::prefix('/notifications')->group(function () {

                Route::get('/rules', [\App\Http\Controllers\CRM\UserNotificationController::class, 'getRules']);
                Route::get('/', [\App\Http\Controllers\CRM\UserNotificationController::class, 'getNotifications']);
                Route::prefix('/{notification}')->group(function () {

                    Route::get('/', [\App\Http\Controllers\CRM\UserNotificationController::class, 'getNotificationInfo']);
                    Route::put('/agree', [\App\Http\Controllers\CRM\UserNotificationController::class, 'agree']);
                    Route::put('/refuse', [\App\Http\Controllers\CRM\UserNotificationController::class, 'refuse']);
                })->where(['notification' => '[0-9]+']);
            });

            Route::get('/info', [\App\Http\Controllers\CRM\UserController::class, 'getCurrentInfo']);
            Route::post('/', [\App\Http\Controllers\CRM\UserController::class, 'create']);
            Route::put('/{user}', [\App\Http\Controllers\CRM\UserController::class, 'edit'])->where(['user' => '[0-9]+']);
            Route::delete('/{user}', [\App\Http\Controllers\CRM\UserController::class, 'remove'])->where(['user' => '[0-9]+']);
            Route::get('/', [\App\Http\Controllers\CRM\UserController::class, 'getList']);
            Route::get('/{user}', [\App\Http\Controllers\CRM\UserController::class, 'getInfo'])->where(['user' => '[0-9]+']);

            //获取岗位类型
            Route::get("/types", [\App\Http\Controllers\CRM\UserTypePointLevelController::class, 'getUserTypes']);
            //岗位管理
            Route::prefix('/roles')->group(function () {

//                Route::post('/', [\App\Http\Controllers\CRM\UserRoleController::class, 'create']);
                Route::put('/{role}', [\App\Http\Controllers\CRM\UserRoleController::class, 'edit']);
//                Route::delete('/{role}', [\App\Http\Controllers\CRM\UserRoleController::class, 'remove']);
                Route::get('/', [\App\Http\Controllers\CRM\UserRoleController::class, 'getList']);
                Route::get('/{role}', [\App\Http\Controllers\CRM\UserRoleController::class, 'getInfo']);
            });

            Route::prefix("/assistants")->group(function () {

                Route::get("/", [\App\Http\Controllers\CRM\AssistantController::class, 'getList']);
                Route::get('/{user}', [\App\Http\Controllers\CRM\AssistantController::class, 'getInfo'])->where(['user' => '[0-9]+']);

                Route::prefix('/types')->group(function () {

                    Route::get('/{type}', [\App\Http\Controllers\CRM\AssistantTypeController::class, 'getInfo']);
                    Route::get('/', [\App\Http\Controllers\CRM\AssistantTypeController::class, 'getList']);
                    Route::post('/', [\App\Http\Controllers\CRM\AssistantTypeController::class, 'create']);
                    Route::put('/{type}', [\App\Http\Controllers\CRM\AssistantTypeController::class, 'edit']);
                    Route::delete('/{type}', [\App\Http\Controllers\CRM\AssistantTypeController::class, 'remove']);
                });
            });

            //岗位积分等级
            Route::prefix("/levels")->group(function () {
                Route::get("/{type}", [\App\Http\Controllers\CRM\UserTypePointLevelController::class, 'getTypeLevel']);
                Route::put("/{type}", [\App\Http\Controllers\CRM\UserTypePointLevelController::class, 'updateTypeLevel']);
            });
        });

        //门店管理
        Route::prefix('/stores')->group(function () {

            Route::post('/', [\App\Http\Controllers\CRM\StoreController::class, 'create']);
            Route::put('/{store}', [\App\Http\Controllers\CRM\StoreController::class, 'edit']);
            Route::delete('/{store}', [\App\Http\Controllers\CRM\StoreController::class, 'remove']);
            Route::get('/', [\App\Http\Controllers\CRM\StoreController::class, 'getList']);
            Route::get('/{store}', [\App\Http\Controllers\CRM\StoreController::class, 'getInfo']);
        });

        //商品管理
        Route::prefix("/goods")->group(function () {

            Route::prefix("/{goods}")->where(['goods' => '[0-9]+'])->group(function () {

                Route::put('/', [\App\Http\Controllers\CRM\GoodsController::class, 'edit']);
                Route::delete('/', [\App\Http\Controllers\CRM\GoodsController::class, 'remove']);
                Route::get('/', [\App\Http\Controllers\CRM\GoodsController::class, 'getInfo']);

                //库存
                Route::prefix("/stocks")->group(function () {

                    Route::get("/logs", [\App\Http\Controllers\CRM\StockController::class, 'getLogList']);
                    Route::post('/', [\App\Http\Controllers\CRM\StockController::class, 'add']);
                    Route::post('/change', [\App\Http\Controllers\CRM\StockController::class, 'change']);
                    Route::post('/reset', [\App\Http\Controllers\CRM\StockController::class, 'reset']);
                });
            });

            Route::post('/', [\App\Http\Controllers\CRM\GoodsController::class, 'create']);


            //商品分类
            Route::prefix("/categories")->group(function () {

                Route::get("/", [\App\Http\Controllers\CRM\CategoryController::class, 'getList']);
                Route::get('/{category}', [\App\Http\Controllers\CRM\CategoryController::class, 'getInfo']);
                Route::post('/', [\App\Http\Controllers\CRM\CategoryController::class, 'create']);
                Route::put('/{category}', [\App\Http\Controllers\CRM\CategoryController::class, 'edit']);
                Route::delete('/{category}', [\App\Http\Controllers\CRM\CategoryController::class, 'remove']);
            });
        });

        //会员管理
        Route::prefix("/members")->group(function () {

            Route::get("/levels", [\App\Http\Controllers\CRM\MemberLevelController::class, 'getLevels']);
            Route::put("/levels", [\App\Http\Controllers\CRM\MemberLevelController::class, 'setLevels']);

            Route::get('/', [\App\Http\Controllers\CRM\MemberController::class, 'getList']);
            Route::post('/', [\App\Http\Controllers\CRM\MemberController::class, 'create']);

            Route::prefix('/{member}')->group(function () {

                Route::get('/', [\App\Http\Controllers\CRM\MemberController::class, 'getInfo']);
                Route::put('/', [\App\Http\Controllers\CRM\MemberController::class, 'edit']);

                Route::get('/money', [\App\Http\Controllers\CRM\MemberMoneyController::class, 'getInfo']);
                Route::get('/money/logs', [\App\Http\Controllers\CRM\MemberMoneyController::class, 'getMoneyLogs']);
            })->where(['member' => '[0-9]+']);
        });

        //数据统计
        Route::prefix("/statistics")->group(function () {

            Route::get("/store/{store}", [\App\Http\Controllers\CRM\StatisticsController::class, 'store']);
        });

        //店铺内数据
        Route::prefix('/{store}')->group(function () {
            //台桌
            Route::prefix('/tables')->group(function () {

                Route::prefix('/{table}')->group(function () {

                    Route::get('/', [\App\Http\Controllers\CRM\TableController::class, 'getTableInfo']);
                    Route::get('/qr', [\App\Http\Controllers\CRM\TableController::class, 'getTableQR']);
                    Route::get('/orders', [\App\Http\Controllers\CRM\TableController::class, 'getTableOrders']);
                    Route::put('/', [\App\Http\Controllers\CRM\TableController::class, 'editTable']);
                    Route::delete('/', [\App\Http\Controllers\CRM\TableController::class, 'removeTable']);
                });

                Route::prefix('/types')->group(function () {

                    Route::get('/{type}', [\App\Http\Controllers\CRM\TableController::class, 'getTableTypes']);
                });
            });

            //服务排名
            Route::prefix('/services')->group(function () {

                Route::get('/user', [\App\Http\Controllers\CRM\ServicesRankController::class, 'userRank']);
                Route::get('/store/user', [\App\Http\Controllers\CRM\ServicesRankController::class, 'getStoreUserCount']);

                Route::get('/assistant', [\App\Http\Controllers\CRM\ServicesRankController::class, 'assistantRank']);
                Route::get('/store/assistant', [\App\Http\Controllers\CRM\ServicesRankController::class, 'getStoreAssistantCount']);

                Route::get('/member', [\App\Http\Controllers\CRM\ServicesRankController::class, 'memberRank']);
                Route::get('/store/member', [\App\Http\Controllers\CRM\ServicesRankController::class, 'getStoreMemberCount']);
            });

            //客户数据
            Route::prefix('/members')->group(function () {

                Route::get('/', [\App\Http\Controllers\CRM\StoreMemberController::class, 'getMemberList']);
                Route::get('/{member}', [\App\Http\Controllers\CRM\StoreMemberController::class, 'getMemberInfo']);
            });

            //订单数据
            Route::prefix('/orders')->group(function () {

                Route::get('/', [\App\Http\Controllers\CRM\OrderController::class, 'getList']);
                Route::get('/{order}', [\App\Http\Controllers\CRM\OrderController::class, 'getInfo']);
            });

            //概览
            Route::prefix('/overview')->group(function () {

                Route::get('/member', [\App\Http\Controllers\CRM\OverviewController::class, 'member']);
                Route::get('/turnover', [\App\Http\Controllers\CRM\OverviewController::class, 'turnover']);
                Route::get('/profit', [\App\Http\Controllers\CRM\OverviewController::class, 'profit']);
                Route::get('/assistant', [\App\Http\Controllers\CRM\OverviewController::class, 'assistant']);
                Route::get('/table', [\App\Http\Controllers\CRM\OverviewController::class, 'table']);
            });
        });

        Route::prefix('/reports')->group(function () {

            Route::get('/member-money', [\App\Http\Controllers\CRM\ReportDataController::class, 'memberMoneyLogs']);

            Route::get('/business', [\App\Http\Controllers\CRM\ReportDataController::class, 'businessReport']);
            Route::get('/table', [\App\Http\Controllers\CRM\ReportDataController::class, 'tableReport']);
            Route::get('/assistant', [\App\Http\Controllers\CRM\ReportDataController::class, 'assistantReport']);
//            Route::get('/member', [\App\Http\Controllers\CRM\ReportDataController::class, 'memberReport']);
            Route::get('/order', [\App\Http\Controllers\CRM\ReportDataController::class, 'orderReport']);
            Route::get('/match', [\App\Http\Controllers\CRM\ReportDataController::class, 'matchReport']);
            Route::get('/point', [\App\Http\Controllers\CRM\ReportDataController::class, 'pointReport']);
            Route::get('/work', [\App\Http\Controllers\CRM\ReportDataController::class, 'workReport']);
        });
    });
});

Route::prefix("/counter")->group(function () {

    Route::post("/login", [\App\Http\Controllers\Counter\UserController::class, 'login']);
    Route::middleware("auth:sanctum")->group(function () {

        Route::prefix("/users")->group(function () {
            Route::get("/info", [\App\Http\Controllers\Counter\UserController::class, 'getCurrentInfo']);
            Route::post("/change-password", [\App\Http\Controllers\Counter\UserController::class, 'changePassword']);
            Route::get("/assistants", [\App\Http\Controllers\Counter\UserController::class, 'getAssistantList']);
            Route::get('/assistants/types', [\App\Http\Controllers\Counter\UserController::class, 'getAssistantTypeList']);
            Route::get("/assistants/status/count", [\App\Http\Controllers\Counter\UserController::class, 'getAssistantStatusCount']);
        });

        Route::prefix('/cost/rule')->group(function () {

            Route::post('/', [\App\Http\Controllers\Counter\CostRuleController::class, 'create']);
            Route::get('/', [\App\Http\Controllers\Counter\CostRuleController::class, 'getList']);
            Route::put('/{costRule}', [\App\Http\Controllers\Counter\CostRuleController::class, 'edit']);
            Route::delete('/{costRule}', [\App\Http\Controllers\Counter\CostRuleController::class, 'delete']);
        });

        Route::prefix('/table')->group(function () {

            Route::get('/status/count', [\App\Http\Controllers\Counter\TableController::class, 'getStatusCounts']);
            Route::get('/{table}', [\App\Http\Controllers\Counter\TableController::class, 'getTableInfo'])->where(['table' => '[0-9]+']);

            Route::post('/{tableType}', [\App\Http\Controllers\Counter\TableController::class, 'addTable'])->where(['tableType' => '[0-9]+']);
            Route::put('/{table}', [\App\Http\Controllers\Counter\TableController::class, 'editTable']);
            Route::delete('/{table}', [\App\Http\Controllers\Counter\TableController::class, 'deleteTable']);

            Route::patch('/repair/{table}', [\App\Http\Controllers\Counter\TableController::class, 'repair']);
            Route::patch('/unrepair/{table}', [\App\Http\Controllers\Counter\TableController::class, 'unrepair']);

            Route::prefix('/type')->group(function () {

                Route::post('/', [\App\Http\Controllers\Counter\TableController::class, 'createType']);
                Route::put('/{tableType}', [\App\Http\Controllers\Counter\TableController::class, 'editType']);
                Route::delete('/{tableType}', [\App\Http\Controllers\Counter\TableController::class, 'deleteType']);
            });

            Route::prefix('/type')->group(function () {

                Route::get('/', [\App\Http\Controllers\Counter\TableController::class, 'getAllTableTypes']);
                Route::get('/{type}', [\App\Http\Controllers\Counter\TableController::class, 'getTableTypes']);
            });

            Route::prefix('/alert')->group(function () {

                Route::prefix('/{table}')->group(function () {

                    Route::post('/cancel', [\App\Http\Controllers\Counter\TableAlertController::class, 'cancel']);
                    Route::post('/add-minutes', [\App\Http\Controllers\Counter\TableAlertController::class, 'addMinutes']);
                    Route::post('/set-date', [\App\Http\Controllers\Counter\TableAlertController::class, 'setAlertDate']);
                })->where(['table' => '[0-9]+']);

                Route::get('/', [\App\Http\Controllers\Counter\TableAlertController::class, 'getExpiredAlertTables']);
                Route::get('/passed', [\App\Http\Controllers\Counter\TableAlertController::class, 'getPassedAlertTables']);
            });
        });

        Route::prefix('/goods')->group(function () {

//            Route::get('/', [\App\Http\Controllers\Counter\GoodsController::class, 'getGoods']);

            Route::prefix('/categories')->group(function () {

                Route::get('/', [\App\Http\Controllers\Counter\CategoryController::class, 'getList']);
            });
        });

        Route::prefix('/members')->group(function () {

            Route::get('/search', [\App\Http\Controllers\MemberController::class, 'search']);
            Route::get('/{member:phone}', [\App\Http\Controllers\MemberController::class, 'info']);
            Route::post('/', [\App\Http\Controllers\MemberController::class, 'create']);
            Route::put('/{member:phone}/password', [\App\Http\Controllers\MemberController::class, 'changePassword']);
        });

        Route::prefix('/orders')->group(function () {

            Route::get('/logs', [\App\Http\Controllers\Counter\OrderLogsController::class, 'getLogs']);

            Route::post('/check', [\App\Http\Controllers\Counter\OrdersController::class, 'ordersCheck']);
            Route::post('/bill', [\App\Http\Controllers\Counter\OrdersController::class, 'ordersBill']);

            Route::get('/', [\App\Http\Controllers\Counter\OrderController::class, 'getOrderList']);
            Route::post('/', [\App\Http\Controllers\Counter\OrderController::class, 'create']);
            Route::post('/virtual', [\App\Http\Controllers\Counter\OrderController::class, 'createVirtualTableOrder']);

            Route::post('/trade/confirm/{tradeOrder}', [\App\Http\Controllers\Counter\OrderController::class, 'onlineTradeConfirm']);

            Route::prefix('/table')->group(function () {

                Route::post('/change', [\App\Http\Controllers\Counter\OrderController::class, 'changeTable']);

                Route::prefix('/{table}')->group(function () {

                    Route::get('/', [\App\Http\Controllers\Counter\OrderController::class, 'getTableOrder']);

                    Route::put('/pause', [\App\Http\Controllers\Counter\TableOrderController::class, 'pause']);
                    Route::put('/unpause', [\App\Http\Controllers\Counter\TableOrderController::class, 'unpause']);
                })->where(['table' => '[0-9]+']);

//                Route::get('/bill', [\App\Http\Controllers\Counter\OrderController::class, 'getTablesBill']);   //已废弃
//                Route::post('/check', [\App\Http\Controllers\Counter\OrderController::class, 'tablesCheck']);   //已废弃
            });

            Route::prefix('/{order}')->group(function () {

                Route::post('/clear/notify', [\App\Http\Controllers\Counter\OrdersController::class, 'notifyClearOrder']);

                Route::prefix('/items/{item}')->group(function () {

                    Route::put('/free', [\App\Http\Controllers\Counter\OrderController::class, 'setOrderItemFree']);
                    Route::put('/pause', [\App\Http\Controllers\Counter\OrderController::class, 'pauseOrderItem']);
                    Route::put('/unpause', [\App\Http\Controllers\Counter\OrderController::class, 'unpauseOrderItem']);
                })->where(['item' => '[0-9]+']);

                Route::get('/', [\App\Http\Controllers\Counter\OrderController::class, 'getOrder']);
                Route::put('/comment', [\App\Http\Controllers\Counter\OrderController::class, 'setOrderComment']);
                Route::get('/bill', [\App\Http\Controllers\Counter\OrderController::class, 'getOrderBill']);
//                Route::post('/check', [\App\Http\Controllers\Counter\OrderController::class, 'orderCheck']);
                Route::post('/pending', [\App\Http\Controllers\Counter\OrderController::class, 'pending']);
                Route::post('/pending-open', [\App\Http\Controllers\Counter\OrderController::class, 'pendingOpen']);
            })->where(['order' => '[0-9]+']);

            Route::post('/goods', [\App\Http\Controllers\Counter\OrderController::class, 'addGoodsItem']);

            Route::prefix('/assistants')->group(function () {

                Route::post('/', [\App\Http\Controllers\Counter\OrderController::class, 'addAssistantItem']);
                Route::post('/check/{item}', [\App\Http\Controllers\Counter\OrderController::class, 'checkAssistantItem']);
                Route::delete('/{item}', [\App\Http\Controllers\Counter\OrderController::class, 'removeAssistantItem']);

                Route::put('/change-table', [\App\Http\Controllers\Counter\AssistantModifyController::class, 'changeTable']);
                Route::put('/change-assistant', [\App\Http\Controllers\Counter\AssistantModifyController::class, 'changeAssistant']);
            });

            Route::prefix('/members/{member}')->group(function () {

//                Route::post('/recharge', [\App\Http\Controllers\Counter\OrderController::class, 'memberRecharge']);
                Route::prefix('/recharge')->group(function () {

                    Route::post('/general', [\App\Http\Controllers\Counter\MemberRechargeController::class, 'general']);
                    Route::post('/table', [\App\Http\Controllers\Counter\MemberRechargeController::class, 'table']);
                });
            });
        });

        Route::prefix('/handover')->group(function () {

            Route::get('/', [\App\Http\Controllers\Counter\HandoverController::class, 'getHandover']);
            Route::get('/bill', [\App\Http\Controllers\Counter\HandoverController::class, 'getHandoverBill']);
            Route::post('/', [\App\Http\Controllers\Counter\HandoverController::class, 'handover']);
        });

        // 快速备注
        Route::prefix('/fast_remarks')->group(function () {

            Route::get('/', [\App\Http\Controllers\Counter\FastRemarkController::class, 'getList']);
            Route::post('/', [\App\Http\Controllers\Counter\FastRemarkController::class, 'create']);
            Route::delete('/{fastRemark}', [\App\Http\Controllers\Counter\FastRemarkController::class, 'remove']);
        });

        // 快速挂单备注 pending

        // 快速结开备注 pending-open
    });
});

Route::prefix('/game')->group(function () {

    Route::get('/', [\App\Http\Controllers\GameController::class, 'getGames']);
    Route::get('/{game}', [\App\Http\Controllers\GameController::class, 'getGame'])->where(['game' => '[0-9]+']);

    Route::post('/', [\App\Http\Controllers\GameController::class, 'create']);
    Route::put('/{game}', [\App\Http\Controllers\GameController::class, 'edit'])->where(['game' => '[0-9]+']);

    Route::prefix('/{game}')->group(function () {

        Route::prefix('/match')->group(function () {

            Route::post('/', [\App\Http\Controllers\GameController::class, 'initMatch']);
            Route::put('/{gameMatch}', [\App\Http\Controllers\GameController::class, 'editMatch'])->scopeBindings();
            Route::patch('/{gameMatch}/win', [\App\Http\Controllers\GameController::class, 'winMatch'])->scopeBindings();
        });
    })->where(['game' => '[0-9]+']);
});

Route::prefix('/members')->group(function () {

    Route::post('/sms_code', [\App\Http\Controllers\SmsController::class, 'member']);
});

Route::prefix('/mini')->group(function () {

    Route::post('/test_login', [\App\Http\Controllers\MiniAPP\UserController::class, 'testLogin']);
    Route::post('/test_pay', [\App\Http\Controllers\MiniAPP\OrderController::class, 'test']);

    Route::prefix('/stores')->group(function () {

        Route::get('/', [\App\Http\Controllers\MiniAPP\StoreController::class, 'getList']);
    });

    Route::post('/login', [\App\Http\Controllers\MiniAPP\UserController::class, 'loginWithTelephone']);
    Route::get('/code2session', [\App\Http\Controllers\MiniAPP\UserController::class, 'miniAppCode2Openid']);

    Route::prefix('/assistants')->group(function () {

        Route::prefix('/types')->group(function () {

            Route::get('/', [\App\Http\Controllers\MiniAPP\AssistantController::class, 'getTypeList']);
        });

        Route::get('/', [\App\Http\Controllers\MiniAPP\AssistantController::class, 'getAssistantList']);
        Route::get('/{assistant}', [\App\Http\Controllers\MiniAPP\AssistantController::class, 'getAssistantInfo']);
    });

    Route::prefix('/tables')->group(function () {

        Route::prefix('/types')->group(function () {

            Route::get('/', [\App\Http\Controllers\MiniAPP\TableController::class, 'getTypeList']);
            Route::get('/{type}', [\App\Http\Controllers\MiniAPP\TableController::class, 'getTypeInfo']);
            Route::get('/{type}/can_reserve', [\App\Http\Controllers\MiniAPP\TableController::class, 'getCanReserve']);
        });
    });

    Route::middleware('auth:member')->group(function () {

        Route::prefix('/orders')->group(function () {

            Route::get('/check/{order:order_no}', [\App\Http\Controllers\MiniAPP\OrderController::class, 'checkOrder']);
            Route::post('/member/recharge', [\App\Http\Controllers\MiniAPP\OrderController::class, 'memberRecharge']);
        });

        Route::prefix('/member/recharge')->group(function () {

            Route::prefix('/options')->group(function () {

                Route::get('/', [\App\Http\Controllers\MiniAPP\MemberRechargeOptionController::class, 'getList']);
            });
        });

        Route::prefix('/user')->group(function () {

            Route::get('/', [\App\Http\Controllers\MiniAPP\UserController::class, 'getInfo']);
            Route::patch('/info', [\App\Http\Controllers\MiniAPP\UserController::class, 'updateInfo']);
        });

        Route::prefix('/assistants')->group(function () {

            Route::get('/{assistant}/can_reserve', [\App\Http\Controllers\MiniAPP\AssistantController::class, 'getCanReserveTime']);
            Route::post('/{assistant}/reserve', [\App\Http\Controllers\MiniAPP\AssistantController::class, 'reserve']);
        });

        Route::prefix('/tables/types')->group(function () {

            Route::post('/{type}/reserve', [\App\Http\Controllers\MiniAPP\TableController::class, 'reserve']);
        });

        Route::prefix('/orders')->group(function () {

            Route::get('/assistants', [\App\Http\Controllers\MiniAPP\AssistantController::class, 'getReserveList']);
            Route::get('/tables', [\App\Http\Controllers\MiniAPP\TableController::class, 'getReserveList']);
        });

        Route::prefix('/duels')->group(function () {

            Route::get('/types', [\App\Http\Controllers\MiniAPP\DuelController::class, 'getDuelTypeList']);
            Route::get('/levels', [\App\Http\Controllers\MiniAPP\DuelController::class, 'getDuelLevelList']);

            Route::post('/', [\App\Http\Controllers\MiniAPP\DuelController::class, 'create']);
            Route::get('/can_sign', [\App\Http\Controllers\MiniAPP\DuelController::class, 'getCanSignDuelList']);
            Route::get('/mine', [\App\Http\Controllers\MiniAPP\DuelController::class, 'getMineDuelList']);

            Route::prefix('/{duel}')->group(function () {

                Route::get('/', [\App\Http\Controllers\MiniAPP\DuelController::class, 'getDuelInfo']);
                Route::post('/sign', [\App\Http\Controllers\MiniAPP\DuelController::class, 'sign']);
            })->where(['duel' => '[0-9]+']);
        });
    });
});
